
import { onUnmounted, watch } from 'vue';
import { useThemeStore } from '@/store';
// 声明并更改主题色
import { setThemeColor } from './utils';
import { setLocal } from '~/src/utils';

export function subscribeTheme(){
  const theme = useThemeStore();
  const addThemeOverrides = watch(
    () => theme.themeColor,
    (newValue) => {
      setLocal( '__THEME_COLOR__', newValue);
      setThemeColor(newValue);
    },
    {
      immediate:true
    }
  );
  onUnmounted(() => {
    addThemeOverrides();
  });
}
